home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / LGP250S1.ZIP / src / libgplus.5 / libgplus / gplus-in / values.h < prev   
C/C++ Source or Header  |  1992-01-17  |  6KB  |  175 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _values_h
  21. #define _values_h 1
  22.  
  23. #define BITSPERBYTE 8
  24. #define BITS(type)  (BITSPERBYTE * (int)sizeof(type))
  25.  
  26. #define CHARBITS    BITS(char)
  27. #define SHORTBITS   BITS(short)
  28. #define INTBITS     BITS(int)
  29. #define LONGBITS    BITS(long)
  30. #define PTRBITS     BITS(char*)
  31. #define DOUBLEBITS  BITS(double)
  32. #define FLOATBITS   BITS(float)
  33.  
  34. #define MINSHORT    ((short)(1 << (SHORTBITS - 1)))
  35. #define MININT      (1 << (INTBITS - 1))
  36. #define MINLONG     (1L << (LONGBITS - 1))
  37.  
  38. #define MAXSHORT    ((short)~MINSHORT)
  39. #define MAXINT      (~MININT)
  40. #define MAXLONG     (~MINLONG)
  41.  
  42. #define HIBITS    MINSHORT
  43. #define HIBITL    MINLONG
  44.  
  45. #if defined(sun) || defined(hp300) || defined(hpux) || defined(masscomp) || defined(sgi)
  46. #ifdef masscomp
  47. #define MAXDOUBLE                            \
  48. ({                                    \
  49.   double maxdouble_val;                            \
  50.                                     \
  51.   __asm ("fmove%.d #0x7fefffffffffffff,%0"    /* Max double */    \
  52.      : "=f" (maxdouble_val)                        \
  53.      : /* no inputs */);                        \
  54.   maxdouble_val;                            \
  55. })
  56. #define MAXFLOAT ((float) 3.40e+38)
  57. #else
  58. #define MAXDOUBLE   1.79769313486231470e+308
  59. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  60. #endif
  61. #define MINDOUBLE   4.94065645841246544e-324
  62. #define MINFLOAT    ((float)1.40129846432481707e-45)
  63. #define _IEEE       1
  64. #define _DEXPLEN    11
  65. #define _FEXPLEN    8
  66. #define _HIDDENBIT  1
  67. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  68. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  69. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  70. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  71.  
  72. #elif defined(sony) 
  73. #define MAXDOUBLE   1.79769313486231470e+308
  74. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  75. #define MINDOUBLE   2.2250738585072010e-308
  76. #define MINFLOAT    ((float)1.17549435e-38)
  77. #define _IEEE       1
  78. #define _DEXPLEN    11
  79. #define _FEXPLEN    8
  80. #define _HIDDENBIT  1
  81. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  82. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  83. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  84. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  85.  
  86. #elif defined(sequent)
  87. extern double _maxdouble, _mindouble;
  88. extern float _maxfloat, _minfloat;
  89. #define MAXDOUBLE    _maxdouble
  90. #define MAXFLOAT    _maxfloat
  91. #define MINDOUBLE    _mindouble
  92. #define MINFLOAT    _minfloat
  93. #define _IEEE       1
  94. #define _DEXPLEN    11
  95. #define _FEXPLEN    8
  96. #define _HIDDENBIT  1
  97. #define DMINEXP     (-(DMAXEXP - 3))
  98. #define FMINEXP     (-(FMAXEXP - 3))
  99. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  100. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  101.  
  102. #elif defined(i386)
  103. #define MAXDOUBLE   1.79769313486231570e+308
  104. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  105. #define MINDOUBLE   2.22507385850720140e-308
  106. #define MINFLOAT    ((float)1.17549435082228750e-38)
  107. #define _IEEE       0
  108. #define _DEXPLEN    11
  109. #define _FEXPLEN    8
  110. #define _HIDDENBIT  1
  111. #define DMINEXP     (-DMAXEXP)
  112. #define FMINEXP     (-FMAXEXP)
  113. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  114. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  115.  
  116. /* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
  117. #elif defined(m88k)
  118.     /* These are "good" guesses ...
  119.        I'll figure out the true mins and maxes later, at the time I find
  120.        out the mins and maxes that the compiler can tokenize. */
  121. #define MAXDOUBLE   1.79769313486231e+308
  122. #define MAXFLOAT    ((float)3.40282346638528e+38)
  123. #define MINDOUBLE   2.22507385850720e-308
  124. #define MINFLOAT    ((float)1.17549435082228e-38)
  125. #define _IEEE       1
  126. #define _DEXPLEN    11
  127. #define _FEXPLEN    8
  128. #define _HIDDENBIT  1
  129. #define DMINEXP     (1-DMAXEXP)
  130. #define FMINEXP     (1-FMAXEXP)
  131. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  132. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  133.  
  134. #elif defined(convex)
  135. #define MAXDOUBLE   8.9884656743115785e+306
  136. #define MAXFLOAT    ((float) 1.70141173e+38)
  137. #define MINDOUBLE   5.5626846462680035e-308
  138. #define MINFLOAT    ((float) 2.93873588e-39)
  139. #define _IEEE       0
  140. #define _DEXPLEN    11
  141. #define _FEXPLEN    8
  142. #define _HIDDENBIT  1
  143. #define DMINEXP     (-DMAXEXP)
  144. #define FMINEXP     (-FMAXEXP)
  145. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  146. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  147.  
  148. // #elif defined(vax)
  149. // use vax versions by default -- they seem to be the most conservative
  150. #else 
  151.  
  152. #define MAXDOUBLE   1.701411834604692293e+38
  153. #define MINDOUBLE   (2.938735877055718770e-39)
  154.  
  155. #define MAXFLOAT    1.7014117331926443e+38
  156. #define MINFLOAT    2.9387358770557188e-39
  157.  
  158. #define _IEEE       0
  159. #define _DEXPLEN    8
  160. #define _FEXPLEN    8
  161. #define _HIDDENBIT  1
  162. #define DMINEXP     (-DMAXEXP)
  163. #define FMINEXP     (-FMAXEXP)
  164. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  165. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  166. #endif
  167.  
  168. #define DSIGNIF     (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
  169. #define FSIGNIF     (FLOATBITS  - _FEXPLEN + _HIDDENBIT - 1)
  170. #define DMAXPOWTWO  ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
  171. #define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
  172.  
  173. #endif
  174.  
  175.